<?php

namespace App\Services;
use App\Facades\Data;

/**
 * Class DfSignService
 * @package App\Service
 * 东方驾校签名校验
 */
class DfService
{
    private $secretKey='KJ30ZnYrzmvaRE9kdnruKCMS64yDwOmC';
    #校区编号
    private $fchrOrgCode='666';

    /**
     * @param $mobile_str
     * 多个手机号用逗号隔开
     * @param $rn
     * 随机数
     * @return string
     */
    public function createSign($mobile_str,$rn){
        $param=[
            'Secretkey' => $this->secretKey,
            'fchrMobile' => $mobile_str,
            'RN' => $rn
        ];
        $http_str=http_build_query($param);
        $http_str=str_replace('%2C',',',$http_str);
        return strtolower(md5($http_str));
    }

    /**
     * @param $mobile_str
     * @param $rn
     * @param $sign
     * 调用驾校接口返回学员信息
     */
    public function getStuInfo($mobile_str,$rn,$sign){
        $url='http://f.dfss.com.cn:8088/QYWX/API/OpenServiceQYWX.ashx?method=GetStuInfoForQW';
        $param=[
            'fchrMobile' => $mobile_str,
            'fchrOrgCode' => $this->fchrOrgCode,
            'RN' => $rn,
            'Signature' => $sign
        ];
        $res=jx_http_request($url,'POST',$param,1);
        $data=[];
        if(!empty($res['Data'])){
            $data=$res['Data'][0];
        }
        Data::setSuccess($data);
    }
}